package com.lsa.skienna.challenge.chap11.the111105_CuttingSticks;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.lsa.helpers.Utils;

public class T2 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        int l = 999;
        int c = 49;
        
        int h = l / c;
        System.out.println(l);
        System.out.println(c);
        
//        List<Integer> cuts = new ArrayList<Integer>();
        List<Integer> cuts = Arrays.asList(26, 48, 65, 81, 109, 128, 143, 166, 188, 202, 222, 247, 267, 286, 309, 327, 341, 368, 389, 400, 421, 440, 461, 483, 509, 525, 545, 568, 586, 603, 628, 643, 664, 683, 706, 725, 743, 768, 782, 801, 828, 847, 865, 883, 903, 922, 940, 960);
        
//        for (int i = 0; i < c; i++) {
//            int perturb = 0;
//            if (i > 0) {
//                perturb = -Utils.random(0, h - 1) / 2;
//                cuts.add((i*h - perturb));
//            }
//        }
        
        int le = 25;
        int ri = 48;
        System.out.println(cuts);
        
        printInterval(le, ri, cuts);
    }
    
    static void printInterval(int le, int ri, List<Integer> cuts){
        int idx = Collections.binarySearch(cuts, le);
        if (idx < 0) {
            idx = -(idx+1);
        }
        int left = idx;
        idx = Collections.binarySearch(cuts, ri);
        if (idx < 0) {
            idx = -(idx+1);
        }
        else {
            idx++;
        }
        int rigth = idx;
        System.out.println(cuts.subList(left, rigth));
        System.out.println(cuts.subList(left, rigth).size());
    }
}
